#include "event_bus.hpp"
#include <iostream>
#include <cstring>

EventBus& EventBus::instance() { 
    static EventBus bus; 
    return bus; 
}

void EventBus::push(const Event& e) {
    std::lock_guard<std::mutex> g(data_mutex); 
    data_queue.push(e); 
}

bool EventBus::pop(Event& e) {
    std::lock_guard<std::mutex> g(data_mutex);
    if(data_queue.empty())
        return false;
    e = data_queue.front();
    data_queue.pop();
    return true;
}